<%--
    User: limeng
    Date: 16/4/26
    Time: 上午8:38
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="panel panel-default">
    <div class="panel-heading">
        <h3>查看消息</h3>
    </div>
    <div class="panel-body" style="min-height: 500px">
        <table class="table table-bordered table-hover text-center">
            <thead>
            <tr>
                <td width="5%"></td>
                <td width="20%">发送者</td>
                <td width="50%">内容简要</td>
                <td width="20%">发送时间</td>
                <td width="5%">类型</td>
            </tr>
            </thead>
            <tbody ng-repeat="message in messages | orderBy:'id':true">
            <tr ng-click="showDialog(message)">
                <td>{{message.unread ? '未读' : '已读'}}</td>
                <td>{{message.sender ? message.sender.name : '系统信息'}}</td>
                <td ng-if="message.content.length <= 35">{{message.content}}</td>
                <td ng-if="message.content.length > 35">{{message.content | limitTo : 33}}…</td>
                <td>{{message.sendTime | date : 'yyyy-MM-d HH:mm:ss'}}</td>
                <td>{{enums.messageType[message.type]}}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="panel-footer">
        <span>当前在第{{pageNo}}页,共{{pageCount}}页</span>
        <div class="btn-group">
            <button class="btn btn-primary" type="button" ng-click="previousPage()">上一页</button>
            <button class="btn btn-primary" type="button" ng-click="nextPage()">下一页</button>
        </div>
        <div class="pull-right">
            <span>
                跳转到第
                <input type="text"
                       ng-model="inputPageNo"
                       style="width: 20px">
                页
            </span>
            <button class="btn btn-primary" type="button" ng-click="jumpPage()">跳转</button>
        </div>
    </div>
</div>

<div class="modal fade" id="readMessageDialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>消息查看</h3>
    </div>
    <div class="modal-body">
        <div class="form-group">
            <label>发送者</label>
            <div class="form-control">
                {{readingMessage.sender ? readingMessage.sender.name : '系统信息'}}
            </div>
            <label>发送时间</label>
            <div class="form-control">
                {{readingMessage.sendTime | date : 'yyyy-MM-d HH:mm:ss'}}
            </div>
            <label>类型</label>
            <div class="form-control">
                {{enums.messageType[readingMessage.type]}}
            </div>
            <label>内容</label>
            <div class="form-control" style="min-height: 300px">
                {{readingMessage.content}}
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" data-dismiss="modal" class="btn btn-danger">关闭</button>
    </div>
</div>